home *** CD-ROM | disk | FTP | other *** search
- DATE Handling routines for C.
-
- Very brief documentation for the dates routines for C. As the
- source code is included you may check it out or change it as you
- wish.
-
- Handling of date data items is difficult if using strings,
- there are many data entry errors possible as well as the
- comparison of string dates is difficult. This package stores
- regular (gregorian) dates as longs to keep the comparisons easy.
- Julian dates are stored in a strucutre and therefore are more
- difficult to use.
-
- The DATES type is defined in the dates.h file as well as the
- prototypes for each function expected to be called from the
- outside world.
-
- The package was developed for my own use and is put into the
- Public Domain for any use, as of 11 Mar 1989 by Gerald Rohr the
- author.
-
- The DATE (long) data item has the date stored as YYYYMMDD and
- the date routines handle the format and information about it.
- This makes it easy to compare and sort by DATEs. The NO_DATE
- define is just a data item of 0L.
-
- The following files should be in the archive which was archived
- with ARC version 5.2:
-
- dates.h header file for dates.c and user files.
- dates.c source code for dates.obj
- dates.obj the small object dates library
- dates.doc this file
- datedemo.c The demo program source code.
- datedemo.exe The compiled demo program
-
- The list of functions and a brief description of each is shown
- below. There is no printer paging to save space and enable you
- to load the dates.doc file into an editor window as a help file.
- I know it is proper to have each function described on a
- seperate page but this sure saves a lot of space and paper.
-
- char *dtoa(DATE in_date)
- Returns character pointer to the string date in the format
- (MM/DD/YYYY).
-
- int day(DATE in_date)
- Returns an integer which is the day portion of a DATE.
-
- int month(DATE in_date)
- Returns an integer which is the month portion of a DATE.
-
- int year(DATE in_date,int cf)
- Returns an integer which is the year portion of a DATE. If cf
- (century flag) is true the returned integer will be 4 digits
- wide (ie 1989) if false the returned integer will be the 2 digit
- year only (ie 89).
-
- DATE jul_to_greg(JULDATE *jdt)
- Returns the DATE (long) value of the information in the JULDATE
- structure passed. Note the value passed to this function is the
- address of the JULDATE structure.
-
- void greg_to_jul(DATE in_date,JULDATE *jdt)
- Converts the Gregorian (DATE) to Julian, As before the address
- of the JULDATE structure you desire the converted Julian date to
- be in is passed to this function.
-
- void prev_day(DATE *dt)
- Subtracts one from DATE variable, The address of the DATE
- variable you wish to be decremented is passed to this function.
-
- void next_day(DATE *dt)
- Adds one to DATE variable, The address of the DATE variable you
- wish to be incremented is passed to this function.
-
- int valid_date(DATE dt)
- Checks if date is valid, returns the following integers informing
- the caller of the results fo the validation. NO_DATE will
- return a valid status.
-
- char *month_name(int mon)
- Returns character pointer to full month name, ie January. The
- returned string is defined as "read only", that is you may read
- (strcpy, etc) the string at the address returned but if you
- write to it, other calls to the function will not return valid
- data.
-
- char *day_name(DATE in_date)
- Returns character pointer to full day of week name, ie
- Wednesday. The returned string is defined as "read only".
-
- int zeller(DATE dt)
- Returns day of week ( 0-6) from date using the Zeller Congruance
- function.
-
- char *jul_dt_st(JULDATE *jdt)
- Returns character pointer to Julian date string in the format
- YYYY/DDD.
-
- char *full_date_st(DATE in_date)
- Returns character pointer to full date string in the format
- "Wednesday March 11, 1989". The returned string is defined as
- "read only".
-
- To get a feel for how these functions work, print a listing of
- the datedemo.c program and refer to it when looking at the
- output of the datedemo.exe program when run.
-
- All functions use prototypes which need to be removed if ported
- to a compiler which does not support them (read Unix). The code
- is very generic and should run under almost any compiler.
-
- In the works are input and output routines to input dates with
- valid date checking as well as incorporating them into the
- windowing functions developed by the Alexandria campus of the
- Northern Virginia Community College, which is also released for
- public use. I have already made many changes to this package and
- as all souce code is included, one can bend it to do what ever
- you wish. After looking at many other windowing packages, this
- seems to be one of the best to start with and the source code is
- included.
-
- The dates.obj file was created using Turbo C version 2.0 for the
- small model. To create any other model, in another directory
- enter the following command line information where the x is
- replaced by the model you wish to use:
-
- tcc -c -mx dates.c<return>
-
- Also available in the Public Domain are the following packages:
-
- grstrings A few string formatters for C.
- tp5wio A complete windowing I/O package for TP5.
- tp5misc Part of tp5wio.
-
- Gerald Rohr Compuserve 70035,1223
- Homogenized Software Genie g.rohr
- RR#3
- Anamosa, Iowa 52205
-